/**
 * Ninth.java created by zhangzhidong 
 * at 下午8:00:16 2015年9月6日
 */
package tencent;

/**
 * @author Alex
 *
 */
public class Ninth {
	int arr1[]=new int[3];
	int arr2[]=new int[3];
	int arr3[]=new int[3];
	public Ninth(){
		arr1[2]=9;
	}
	public boolean methodR1(){
		return (arr1[0]+arr1[1]-arr1[2] ==4) && (arr2[0] -arr2[1]* arr2[2] ==4 )&& (arr3[0] +arr3[1]-arr3[2] ==4);
	}

	public boolean methodC1(){
		if(arr3[0]==0) return false;
		
		if(arr2[0]/arr3[0]*arr3[0]!=arr2[0]) return false;
		
		return (arr1[0] +arr2[0] / arr3[0] ==4 )&& (arr1[1] -arr2[1]*arr3[1] ==4 )&& (arr1[2] -arr2[2]-arr3[2] ==4);
	}
	public void set(int [] num){		
			System.arraycopy(num, 0, arr1,0, 3);
			System.arraycopy(num, 3, arr2,0, 3);
			System.arraycopy(num, 6, arr3, 0, 3);
	}
	
	public static void main1(String arts[]){
		int i=5;
		int a=2;
		System.out.println((double)i/a);
	}
	
	public static void main(String args[]){
		Ninth n = new Ninth();
		int arr[] = new int[9];
		for(int a = 0;a<=4;a++){
			for(int d =8;d<=13;d++){
				for(int f =1;f<=5;f++){					
						arr[0]=a;
						arr[1]=13-a;
						arr[2]=9;
						arr[3]=d;
						arr[5]=f;
						arr[8]=5-f;				
						for(int e=1;e<9;e++){
							for(int h =1;h<9;h++){
							arr[4]=e;
							arr[7]=h;
							arr[6]=4+arr[8]-h;							
							n.set(arr);
							if(n.methodC1() && n.methodR1()){
								for(int i=0;i<arr.length;i++){
									System.out.print(arr[i]+",");
								}
								System.out.println();
							}
							
							
							
							}
						}					
				}
			}
		}
	}
}
